<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="javax.xml.parsers.DocumentBuilderFactory,javax.xml.parsers.DocumentBuilder,
				 org.w3c.dom.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>中醫體質評量系統</title>
<script language="Javascript" type="text/javascript">
function check(){
	var menubox_obj = document.getElementsByName("menubox");
	var menubox_len = menubox_obj.length;
	var menubox_check = false;	
	var i;

	for(i=0;i<menubox_len;i++){
		if(menubox_obj[i].checked == true){
			menubox_check = true;
			break;
		}
	}
	if(!menubox_check){
		alert("請勾選菜單");
		return;
	}
	document.menuform.submit();
}

function showtabel(){
	if (document.getElementById("table").className == "off")
		document.getElementById("table").className = "on";
	else
		document.getElementById("table").className = "off";
}

</script>
<style type="text/css">
<!--
body {
	background-image: url(img/grass.jpg);
    background-position: center top;
	background-color: #FFFFFF;
	background-repeat: repeat;
}
body,td,th {
	color: #000000;
	font-size:24px;
	font-family: Arial;
}



a:link {
text-decoration:none;
font-family:Arial;
font-size:20px;
color:#FFFFFF;
}
a:visited {
text-decoration:none;
font-family:Arial;
font-size:20px;
color:#FFFFFF;
}
a:hover {
text-decoration:none;
font-family:Arial;
font-size:20px;
color:#000000;
}

.class2 a:link {
text-decoration:none;
font-family:"標楷體";
font-size:20px;
color:#000000;
}
.class2 a:visited {
text-decoration:none;
font-family:"標楷體";
font-size:20px;
color:#000000;
}
.class2 a:active {
text-decoration:none;
font-family:"標楷體";
font-size:20px;
color:#0000FF;
}
.class2 a:hover {
text-decoration:none;
font-family:"標楷體";
font-size:20px;
color:#0000FF;
}

.ind:link {
color: #535353;
text-decoration:none;
font-family:"標楷體";
font-size:18px;
}
.ind:visited {
color:#535353;
text-decoration:none;
font-family:"標楷體";
font-size:18px;
}

.ind:hover {
color:#BB280F;
text-decoration:none;
font-family:"標楷體";
font-size:18px;
}

 .off { display:none;}
 .on  { display:block;}

.HEAD_STYLE {
	font-weight:bold;
	color: #437A27;
	font-family:"標楷體";
	font-size:30px; 
}

.TEXT_STYLE{
	font-family:"標楷體";  
	color:#000000;
	font-size:24px;
}
.BOTTOM_STYLE {
	color: #FFFFFF; 
	font-family: Arial; 
	font-size:20px;
}
.LEFT_BUTTON {
	font-family:"標楷體"; 
	font-size:30px;
}
.button
{
	border:1px;
	padding-top: 4px;
	padding-right: 7px;
	padding-bottom: 4px;
	padding-left: 7px;
	background-color: #468129;
	color: #FFFFFF;
	font-size: 16px;
	border-color: #3C7023;
}
.style3 {color: #437A27; font-weight: bold; }

-->
</style>
</head>
<body alink="#FF0000" vlink="#FF0000">
<%
	String path = "./WEB-INF/menu.xml";
	Document menu = null;
	String File = request.getRealPath(path);
	DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
	try{
		DocumentBuilder builder = factory.newDocumentBuilder();	
		menu = builder.parse(File);	
	}catch(Exception e){
		out.print("XML analysis error" + e.getMessage());
	}
	Element body = menu.getDocumentElement();
	NodeList menuList = body.getElementsByTagName("dish"); 
	String dish = "";
%>

<table width="100%" border="0">
	<tr>
		<td><p>&nbsp;</p></td>
	</tr>
	<tr>					
		<td width="5%">&nbsp;</td>
		<td bgcolor="#FFFFFF">
			<table width="100%" border="0">
				<tr>
					<td background="img/herbal.jpg">
						<p>&nbsp;</p>
						<p>&nbsp;</p>
						<p>&nbsp;</p>
						<p>&nbsp;</p>
						<p>&nbsp;</p>
					</td>
				</tr>
				<tr>
					<td>	
						<table bgcolor="#437A27" width="100%" border="0">
							<tr>
								<td>&nbsp;</td>
								<td width="20%" align="center"><a href="main.jsp" target="_parent">回到主選單</a></td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td>
						<table width="100%">
							<tr>
								<td valign="top">
									<table width="100%">
									
									<form name="menuform" action="menulist.do" method="post">
										<tr>
											<td class="HEAD_STYLE" align="center">飲食評量</td>
										</tr>
										<tr>
											<td >

												<table width="90%"align="center" border="1">
													<tr>
														<td class="TEXT_STYLE">
																<span class="style3">請參考以下菜單，填入您計畫中的一餐飲食，我們將為您分析：</span><br>
																
																<%
																for( int i = 0 ; i < menuList.getLength() ; i++ )
																{
																Node node = menuList.item(i);	
															    dish = node.getAttributes().getNamedItem("name").getNodeValue();
																
																%>
																<input type="checkbox" name="menubox" value="<%=dish%>"/><%=dish%>   
																<br><% 
																} // end for
																%>
																<hr>
																<%	if ( request.isUserInRole("admin") || request.isUserInRole("user") ) {	%>	
																<%	if ( request.isUserInRole("admin")) %>
																<input  type="radio"   name="user" value="general" >一般使用者<br>
																<table id="general_work" width="90%"align="center" >
																	&nbsp; <input type="radio" name="work" value="little">輕度工作<br>																					
																	&nbsp;&nbsp;&nbsp;&nbsp;大部分從事靜態或坐著的工作。例如：家庭主婦、坐辦公室的上班族、售貨員<br>
																	&nbsp; <input type="radio" name="work" value="middle">中度工作<br>
																	&nbsp;&nbsp;&nbsp;&nbsp;從事機械操作、接待或家事等站立活動較多的工作。例如：褓母、護士、服務生<br>
																	&nbsp; <input type="radio" name="work" value="large">重度工作<br>
																	&nbsp;&nbsp;&nbsp;&nbsp;從事農耕、漁業、建築等的重度使用體力之工作。例如：運動員、搬家工<br>
															    </table> 
																<% } %>
																
																<%	if ( request.isUserInRole("admin") || request.isUserInRole("professional") ) {	%>
																<%	if ( request.isUserInRole("admin")) %>
																<input  type="radio"   name="user" value="professional" >專業使用者<br>
																<table id="pro_work" width="90%"align="center" >
																	&nbsp; <span>活動因子：</span>&nbsp;
																	<input  type="radio"   name="activity" value="little">臥床&nbsp;&nbsp;
																	<input  type="radio"   name="activity" value="middle">輕度活動&nbsp;&nbsp;
																	<input  type="radio"   name="activity" value="large">中度活動<br>
																	&nbsp; <span>壓力因子：</span>
																	<input type="text" name="pressure" size="5" class="input_text" style="text-align:right">
																	(<span class="class2"><a href="javascript:showtabel()" >參考</a></span>)
																</table>
																
																<br>
																<table width="70%" align="center" frame="border" rules="all" id="table" class="off">
																	<tr>
																		<td align="center" class="TEXT_STYLE"><span>壓力</span></td>
																		<td align="center" class="TEXT_STYLE"><span>因子</span></td>
																	</tr>
																	<tr>
																		<td align="center" class="TEXT_STYLE"><span>輕度飢餓</span></td>
																		<td align="center" class="TEXT_STYLE"><span>0.85~1.0</span></td>
																	</tr>
																	<tr>
																		<td align="center" class="TEXT_STYLE"><span>小手術或癌症</span></td>
																		<td align="center" class="TEXT_STYLE"><span>1.2</span></td>
																	</tr>
																	<tr>
																		<td align="center" class="TEXT_STYLE"><span>腹膜炎</span></td>
																		<td align="center" class="TEXT_STYLE"><span>1.05~1.25</span></td>
																	</tr>
																	<tr>
																		<td align="center" class="TEXT_STYLE"><span>骨折、骨骼創傷</span></td>
																		<td align="center" class="TEXT_STYLE"><span>1.3</span></td>
																	</tr>
																	<tr>
																		<td align="center" class="TEXT_STYLE"><span>發燒1°C</span></td>
																		<td align="center" class="TEXT_STYLE"><span>1.13</span></td>
																	</tr>
																	<tr>
																		<td align="center" class="TEXT_STYLE"><span>生長</span></td>
																		<td align="center" class="TEXT_STYLE"><span>1.4</span></td>
																	</tr>
																	<tr>
																		<td align="center" class="TEXT_STYLE"><span>懷孕</span></td>
																		<td align="center" class="TEXT_STYLE"><span>1.1</span></td>
																	</tr>
																	<tr>
																		<td align="center" class="TEXT_STYLE"><span>哺乳</span></td>
																		<td align="center" class="TEXT_STYLE"><span>1.4</span></td>
																	</tr>
																	<tr>
																		<td align="center" class="TEXT_STYLE"><span>敗血</span></td>
																		<td align="center" class="TEXT_STYLE"><span>1.4~1.8</span></td>
																	</tr>
																	<tr>
																		<td align="center" class="TEXT_STYLE"><span>燒傷30%</span></td>
																		<td align="center" class="TEXT_STYLE"><span>1.7</span></td>
																	</tr>
																	<tr>
																		<td align="center" class="TEXT_STYLE"><span>燒傷50%</span></td>
																		<td align="center" class="TEXT_STYLE"><span>2.0</span></td>
																	</tr>
																	<tr>
																		<td align="center" class="TEXT_STYLE"><span>燒傷70%</span></td>
																		<td align="center" class="TEXT_STYLE"><span>2.2</span></td>
																	</tr>
																	<tr>
																		<td align="center" class="TEXT_STYLE"><span>癌症惡病質</span></td>
																		<td align="center" class="TEXT_STYLE"><span>1.2~1.4</span></td>
																	</tr>
																</table>
																<br>
																<% } %>															
													  </td>
													</tr>
												</table>											
											</td>
										</tr>
										<tr><center>
											<td align="center">
											<input type="button" value="送出" class="button" onClick="check()">	
										
											<input  class="button" type="button" value="回到主選單" onClick="location='main.jsp'"/>
											</td>	
											</center>
										</tr>
										</form>
									</table>
								</td>
							</tr>
						</table>
					
					
					</td>
				</tr>
				<tr>
					<td><p>&nbsp;</p></td>
				</tr>
				<tr>
					<td bgcolor="#437A27"><div align="center" class="BOTTOM_STYLE">Copyright@ITRI and CCU_PLlab</div></td>
				
				</tr>
						
			</table>
		</td>
		<td width="5%">&nbsp;</td>
	</tr>			


</table>
<p>&nbsp;</p>


</body>
</html>